2000W / 48V LLC Battery-Charger  V1.00

System Control Unit(SCU) driver for XMC microcontroller family. More...

Collaboration diagram for SCU:

Typedefs

typedef enum XMC_SCU_STATUS XMC_SCU_STATUS_t
 
typedef void(* XMC_SCU_INTERRUPT_EVENT_HANDLER_t) (void)
 

Enumerations

enum  XMC_SCU_STATUS { XMC_SCU_STATUS_OK = 0UL, XMC_SCU_STATUS_ERROR, XMC_SCU_STATUS_BUSY }
 

Functions

__STATIC_INLINE void XMC_SCU_SetCcuTriggerHigh (const uint32_t trigger)
 
__STATIC_INLINE void XMC_SCU_SetCcuTriggerLow (const uint32_t trigger)
 
void XMC_SCU_CLOCK_Init (const XMC_SCU_CLOCK_CONFIG_t *const config)
 
void XMC_SCU_INTERRUPT_EnableEvent (const XMC_SCU_INTERRUPT_EVENT_t event)
 
void XMC_SCU_INTERRUPT_DisableEvent (const XMC_SCU_INTERRUPT_EVENT_t event)
 
void XMC_SCU_INTERRUPT_TriggerEvent (const XMC_SCU_INTERRUPT_EVENT_t event)
 
XMC_SCU_INTERRUPT_EVENT_t XMC_SCU_INTERUPT_GetEventStatus (void)
 
void XMC_SCU_INTERRUPT_ClearEventStatus (const XMC_SCU_INTERRUPT_EVENT_t event)
 
__STATIC_INLINE uint32_t XMC_SCU_RESET_GetDeviceResetReason (void)
 
__STATIC_INLINE void XMC_SCU_RESET_ClearDeviceResetReason (void)
 
__STATIC_INLINE uint32_t XMC_SCU_CLOCK_GetCpuClockFrequency (void)
 
uint32_t XMC_SCU_CLOCK_GetPeripheralClockFrequency (void)
 
void XMC_SCU_CLOCK_GatePeripheralClock (const XMC_SCU_PERIPHERAL_CLOCK_t peripheral)
 
void XMC_SCU_CLOCK_UngatePeripheralClock (const XMC_SCU_PERIPHERAL_CLOCK_t peripheral)
 
bool XMC_SCU_CLOCK_IsPeripheralClockGated (const XMC_SCU_PERIPHERAL_CLOCK_t peripheral)
 
__STATIC_INLINE uint32_t XMC_SCU_GetMirrorStatus (void)
 
XMC_SCU_STATUS_t XMC_SCU_INTERRUPT_SetEventHandler (const XMC_SCU_INTERRUPT_EVENT_t event, const XMC_SCU_INTERRUPT_EVENT_HANDLER_t handler)
 
void XMC_SCU_IRQHandler (uint32_t sr_num)
 

Detailed Description

System Control Unit(SCU) driver for XMC microcontroller family.

System control unit is the SoC power, reset and a clock manager with additional responsibility of providing system stability protection and other auxiliary functions.
SCU provides the following features,

  1. Power control
  2. Reset control
  3. Clock control
  4. Miscellaneous control(boot mode, system interrupts etc.)

The SCU driver is divided in to clock control logic, reset control logic, system interrupt control logic and miscellaneous control logic.

Clock driver features:

  1. Allows clock configuration using the structure XMC_SCU_CLOCK_CONFIG_t and API XMC_SCU_CLOCK_Init()

Reset driver features:

Interrupt driver features:

  1. Provides APIs for enabling/ disabling interrupt event generation XMC_SCU_INTERRUPT_EnableEvent(), XMC_SCU_INTERRUPT_DisableEvent()
  2. Provides API for registering callback function for events XMC_SCU_INTERRUPT_SetEventHandler()

Miscellaneous features:

  1. Allows to trigger multiple capture compare unit(CCU) channels to be started together XMC_SCU_SetCcuTriggerHigh()

Typedef Documentation

◆ XMC_SCU_INTERRUPT_EVENT_HANDLER_t

typedef void(* XMC_SCU_INTERRUPT_EVENT_HANDLER_t) (void)

Function pointer type used for registering callback functions on SCU event occurrence.

Definition at line 187 of file xmc_scu.h.

◆ XMC_SCU_STATUS_t

Defines the status of SCU API execution, used to verify the SCU related API calls.

Enumeration Type Documentation

◆ XMC_SCU_STATUS

Defines the status of SCU API execution, used to verify the SCU related API calls.

Enumerator
XMC_SCU_STATUS_OK 

SCU related operation successfully completed.

XMC_SCU_STATUS_ERROR 

SCU related operation failed. When API cannot fulfill request, this value is returned.

XMC_SCU_STATUS_BUSY 

Cannot execute the SCU related operation request because another operation is in progress. XMC_SCU_STATUS_BUSY is returned when API is busy processing another request.

Definition at line 170 of file xmc_scu.h.

Function Documentation

◆ XMC_SCU_CLOCK_GatePeripheralClock()

void XMC_SCU_CLOCK_GatePeripheralClock ( const XMC_SCU_PERIPHERAL_CLOCK_t  peripheral)
Parameters
peripheralThe peripheral for which the clock has to be gated. Range: Use type XMC_SCU_PERIPHERAL_CLOCK_t to identify the peripheral clock to be gated.
Returns
None
Description
Blocks the supply of clock to the selected peripheral.

Clock gating helps in reducing the power consumption. User can selectively gate the clocks of unused peripherals. Note: Clock gating shall not be activated unless the module is in reset state. So use XMC_SCU_CLOCK_IsPeripheralClockGated() API before enabling the gating of any peripheral.
Related APIs:
XMC_SCU_CLOCK_IsPeripheralClockGated(), XMC_SCU_CLOCK_UngatePeripheralClock()


Definition at line 628 of file xmc1_scu.c.

Referenced by XMC_RTC_Disable(), XMC_USIC_Disable(), XMC_VADC_GLOBAL_DisableModule(), and XMC_WDT_Disable().

Here is the caller graph for this function:

◆ XMC_SCU_CLOCK_GetCpuClockFrequency()

__STATIC_INLINE uint32_t XMC_SCU_CLOCK_GetCpuClockFrequency ( void  )
Returns
uint32_t Value of CPU clock frequency.
Description
Provides the vlaue of CPU clock frequency.

The value is stored in a global variable SystemCoreClock. It is updated when the clock configuration is done using the SCU LLD APIs. The value represents the frequency of clock used for CPU operation. Range: Value is of type uint32_t, and gives the value of frequency in Hertz.
Related APIs:
XMC_SCU_CLOCK_GetPeripheralClockFrequency(), XMC_SCU_CLOCK_GatePeripheralClock()


Definition at line 425 of file xmc_scu.h.

◆ XMC_SCU_CLOCK_GetPeripheralClockFrequency()

uint32_t XMC_SCU_CLOCK_GetPeripheralClockFrequency ( void  )
Returns
uint32_t Value of peripheral clock frequency in Hertz.
Description
Provides the vlaue of clock frequency at which the peripherals are working.

The value is derived from the CPU frequency. Range: Value is of type uint32_t. It is represented in Hertz.
Related APIs:
XMC_SCU_CLOCK_GetCpuClockFrequency(),XMC_SCU_CLOCK_GatePeripheralClock()


Definition at line 792 of file xmc1_scu.c.

Referenced by XMC_I2S_CH_SetBaudrate(), XMC_SPI_CH_SetBaudrate(), XMC_SPI_CH_SetInterwordDelay(), XMC_UART_CH_SetBaudrate(), and XMC_USIC_CH_SetBaudrate().

Here is the caller graph for this function:

◆ XMC_SCU_CLOCK_Init()

void XMC_SCU_CLOCK_Init ( const XMC_SCU_CLOCK_CONFIG_t *const  config)
Parameters
configPointer to structure holding the clock prescaler values and divider values for configuring clock generators and clock tree.
Range: Configure the members of structure XMC_SCU_CLOCK_CONFIG_t for various parameters of clock setup.
Returns
None
Description
Initializes clock generators and clock tree.

Related APIs:
XMC_SCU_CLOCK_GetPeripheralClockFrequency(), XMC_SCU_CLOCK_GetCpuClockFrequency()


Definition at line 545 of file xmc1_scu.c.

◆ XMC_SCU_CLOCK_IsPeripheralClockGated()

bool XMC_SCU_CLOCK_IsPeripheralClockGated ( const XMC_SCU_PERIPHERAL_CLOCK_t  peripheral)
Parameters
peripheralThe peripheral for which the check for clock gating has to be done. Range: Use type XMC_SCU_PERIPHERAL_CLOCK_t to identify the peripheral.
Returns
bool Status of the peripheral clock gating. Range: true if the peripheral clock is gated. false if the peripheral clock ungated(gate de-asserted).
Description
Gives the status of peripheral clock gating.

It is recommended to use this API before enabling the gating of any peripherals through XMC_SCU_CLOCK_GatePeripheralClock() API.
Related APIs:
XMC_SCU_CLOCK_UngatePeripheralClock(), XMC_SCU_CLOCK_GatePeripheralClock()


Definition at line 648 of file xmc1_scu.c.

Referenced by XMC_RTC_IsEnabled().

Here is the caller graph for this function:

◆ XMC_SCU_CLOCK_UngatePeripheralClock()

void XMC_SCU_CLOCK_UngatePeripheralClock ( const XMC_SCU_PERIPHERAL_CLOCK_t  peripheral)
Parameters
peripheralThe peripheral for which the clock has to be ungated. Range: Use type XMC_SCU_PERIPHERAL_CLOCK_t to identify the peripheral.
Returns
None
Description
Enables the supply of clock to the selected peripheral.

By default when the device powers on, the peripheral clock will be gated for the peripherals that support clock gating. The peripheral clock should be enabled before using it for any functionality.
Related APIs:
XMC_SCU_CLOCK_IsPeripheralClockGated(), XMC_SCU_CLOCK_GatePeripheralClock()


Definition at line 636 of file xmc1_scu.c.

Referenced by XMC_RTC_Enable(), XMC_USIC_Enable(), XMC_VADC_GLOBAL_EnableModule(), and XMC_WDT_Enable().

Here is the caller graph for this function:

◆ XMC_SCU_GetMirrorStatus()

__STATIC_INLINE uint32_t XMC_SCU_GetMirrorStatus ( void  )
Returns
uint32_t Status of the register mirror update.
Range: Use the bit mask of the SCU_GENERAL_MIRRSTS register for the mirror update event of interest. e.g.: SCU_GENERAL_MIRRSTS_RTC_CTR_Msk. Multiple update events can be combined using OR operation.
Description
Provides the status of hibernate domain register update, when the respective mirror registers are changed.

The hibernate domain is connected to the core domain via SPI serial communication. MIRRSTS is a status register representing the communication of changed value of a mirror register to its corresponding register in the hibernate domain. The bit fields of the register indicate that a corresponding register of the hibernate domain is ready to accept a write or that the communication interface is busy with executing the previous operation.
Note: There is no hibernate domain in XMC1x devices. This register is retained for legacy purpose.

Definition at line 543 of file xmc_scu.h.

Referenced by XMC_RTC_Init(), XMC_RTC_SetAlarm(), XMC_RTC_SetPrescaler(), XMC_RTC_SetTime(), XMC_RTC_Start(), and XMC_RTC_Stop().

Here is the caller graph for this function:

◆ XMC_SCU_INTERRUPT_ClearEventStatus()

void XMC_SCU_INTERRUPT_ClearEventStatus ( const XMC_SCU_INTERRUPT_EVENT_t  event)
Parameters
eventBit mask of the events to clear. Range: Use type XMC_SCU_INTERRUPT_EVENT_t for providing the input value. Multiple events can be combined using the OR operation.
Returns
None
Description
Clears the event status bit in SRRAW register.

The events are cleared by writing value 1 to their bit positions in the SRCLR register. The API can be used when polling method is used. After detecting the event, the event status should be cleared using software to detect the event again.
Related APIs:
XMC_SCU_INTERUPT_GetEventStatus(), XMC_SCU_INTERRUPT_TriggerEvent()


Definition at line 397 of file xmc1_scu.c.

Referenced by L1_Lade_Zusatz_Funktionen_Master(), and L1_Lade_Zusatz_Funktionen_Slave().

Here is the caller graph for this function:

◆ XMC_SCU_INTERRUPT_DisableEvent()

void XMC_SCU_INTERRUPT_DisableEvent ( const XMC_SCU_INTERRUPT_EVENT_t  event)
Parameters
eventBit mask of the event to disable. Range: Use type XMC_SCU_INTERRUPT_EVENT_t for providing the input value. Multiple events can be combined using the OR operation.
Returns
None
Description
Disables generation of interrupt on occurrence of the input event.

The events are disabled by resetting the respective bit fields in the SRMSK register.
Related APIs:
NVIC_DisableIRQ(), XMC_SCU_INTERRUPT_EnableEvent()


Definition at line 367 of file xmc1_scu.c.

◆ XMC_SCU_INTERRUPT_EnableEvent()

void XMC_SCU_INTERRUPT_EnableEvent ( const XMC_SCU_INTERRUPT_EVENT_t  event)
Parameters
eventBit mask of the event to enable. Range: Use type XMC_SCU_INTERRUPT_EVENT_t for providing the input value. Multiple events can be combined using the OR operation.
Returns
None
Description
Enables the generation of interrupt for the input events.

The events are enabled by setting the respective bit fields in the SRMSK register.
Note: User should separately enable the NVIC node responsible for handling the SCU interrupt. The interrupt will be generated when the respective event occurs.
Related APIs:
NVIC_EnableIRQ(), XMC_SCU_INTERRUPT_DisableEvent()


Definition at line 358 of file xmc1_scu.c.

◆ XMC_SCU_INTERRUPT_SetEventHandler()

XMC_SCU_STATUS_t XMC_SCU_INTERRUPT_SetEventHandler ( const XMC_SCU_INTERRUPT_EVENT_t  event,
const XMC_SCU_INTERRUPT_EVENT_HANDLER_t  handler 
)
Parameters
eventThe event for which the interrupt handler is to be configured.
Range: Use type XMC_SCU_INTERRUPT_EVENT_t for identifying the event.
handlerName of the function to be executed when the event if detected.
Range: The function accepts no arguments and returns no value.
Returns
XMC_SCU_STATUS_t Status of configuring the event handler function for the selected event.
Range: XMC_SCU_STATUS_OK if the event handler is successfully configured.
XMC_SCU_STATUS_ERROR if the input event is invalid.
Description
Assigns the event handler function to be executed on occurrence of the selected event.

If the input event is valid, the handler function will be assigned to a table to be executed when the interrupt is generated and the event status is set in the event status register. By using this API, polling for a particular event can be avoided. This way the CPU utilization will be optimized. Multiple SCU events can generate a common interrupt. When the interrupt is generated, a common interrupt service routine is executed. It checks for status flags of events which can generate the interrupt. The handler function will be executed if the event flag is set.
Related APIs:
XMC_SCU_INTERRUPT_TriggerEvent(), XMC_SCU_INTERUPT_GetEventStatus()


Definition at line 828 of file xmc1_scu.c.

◆ XMC_SCU_INTERRUPT_TriggerEvent()

void XMC_SCU_INTERRUPT_TriggerEvent ( const XMC_SCU_INTERRUPT_EVENT_t  event)
Parameters
eventBit mask of the event to be triggered. Range: Use type XMC_SCU_INTERRUPT_EVENT_t for providing the input value. Multiple events can be combined using the OR operation.
Returns
None
Description
Triggers the event as if the hardware raised it.

Event will be triggered by setting the respective bitfield in the SRSET register.
Note: User should enable the NVIC node that handles the respective event for interrupt generation.
Related APIs:
NVIC_EnableIRQ(), XMC_SCU_INTERUPT_GetEventStatus(), XMC_SCU_INTERRUPT_ClearEventStatus()


Definition at line 376 of file xmc1_scu.c.

◆ XMC_SCU_INTERUPT_GetEventStatus()

XMC_SCU_INTERRUPT_EVENT_t XMC_SCU_INTERUPT_GetEventStatus ( void  )
Returns
uint32_t Status of the SCU events.
Description
Provides the status of all SCU events.

The status is read from the SRRAW register. To check the status of a particular event, the returned value should be masked with the bit mask of the event. The bitmask of events can be obtained using the type XMC_SCU_INTERRUPT_EVENT_t. Multiple events' status can be checked by combining the bit masks using OR operation. After detecting the event, the event status should be cleared using software to detect the event again.
Related APIs:
XMC_SCU_INTERRUPT_ClearEventStatus(), XMC_SCU_INTERRUPT_TriggerEvent(), XMC_SCU_INTERRUPT_SetEventHandler()


Definition at line 385 of file xmc1_scu.c.

◆ XMC_SCU_IRQHandler()

void XMC_SCU_IRQHandler ( uint32_t  sr_num)
Parameters
sr_numService request number identifying the SCU interrupt generated.
Range: 0 to 2. XMC4x devices have one common SCU interrupt, so the value should be 0.
But XMC1x devices support 3 interrupt nodes.
Returns
None
Description
A common function to execute callback functions for multiple events.

It checks for the status of events which can generate the interrupt with the selected service request. If the event is set, the corresponding callback function will be executed. It also clears the event status bit.
Note: This is an internal function. It should not be called by the user application.
Related APIs:
XMC_SCU_INTERRUPT_SetEventHandler()


Definition at line 859 of file xmc1_scu.c.

◆ XMC_SCU_RESET_ClearDeviceResetReason()

__STATIC_INLINE void XMC_SCU_RESET_ClearDeviceResetReason ( void  )
Returns
None
Description
Clears the reset reason bits in the reset status register.

Clearing of the reset status information in the SCU_RSTSTAT register via register bit RSTCLR.RSCLR is strongly recommended to ensure a clear indication of the cause of next reset.
Related APIs:
XMC_SCU_RESET_GetDeviceResetReason()


Definition at line 406 of file xmc_scu.h.

◆ XMC_SCU_RESET_GetDeviceResetReason()

__STATIC_INLINE uint32_t XMC_SCU_RESET_GetDeviceResetReason ( void  )
Returns
uint32_t Status representing the reason for device reset.
Description
Provides the value representing the reason for device reset.

The return value is an encoded word, which can indicate multiple reasons for the last reset. Each bit position of the returned word is representative of a last reset cause. The returned value should be appropriately masked to check the cause of reset. The cause of the last reset gets automatically stored in the SCU_RSTSTAT register. The reset status shall be reset after each startup in order to ensure consistent source indication after the next reset. Range: The type XMC_SCU_RESET_REASON_t can be used to get the bit masks of the reset cause.
Related APIs:
XMC_SCU_RESET_ClearDeviceResetReason()


Definition at line 391 of file xmc_scu.h.

◆ XMC_SCU_SetCcuTriggerHigh()

__STATIC_INLINE void XMC_SCU_SetCcuTriggerHigh ( const uint32_t  trigger)
Parameters
triggerCCU slices to be triggered synchronously via software. The value is a bitmask of CCU slice bits in the register CCUCON.
Range: Use type XMC_SCU_CCU_TRIGGER_t for bitmask of individual CCU slices. Multiple slices can be combined using OR operation.
Returns
None
Description
Generates active edge(low to high) trigger for multiple CCU units at the same time.

Before executing this API, all the required CCU timers should configure external start. The edge of the start signal should be selected as active edge. The input signal for the CCU slice should be selected as SCU input. The above mentioned configurations can be made using the CCU LLD API XMC_CCU4_SLICE_StartConfig(). CCU timer slice should be started using XMC_CCU4_SLICE_StartTimer() before triggering the timer using this API.
Related APIs:
XMC_CCU4_SLICE_StartConfig(), XMC_CCU4_SLICE_SetInput(), XMC_SCU_SetCcuTriggerLow()


Definition at line 230 of file xmc_scu.h.

◆ XMC_SCU_SetCcuTriggerLow()

__STATIC_INLINE void XMC_SCU_SetCcuTriggerLow ( const uint32_t  trigger)
Parameters
triggerCCU slices to be triggered synchronously via software. The value is a bitmask of CCU slice bits in the register CCUCON.
Range: Use type XMC_SCU_CCU_TRIGGER_t for bitmask of individual CCU slices. Multiple slices can be combined using OR operation.
Returns
None
Description
Generates passive edge(high to low) trigger for multiple CCU units at the same time.

Before executing this API, all the required CCU timers should configure external start. The edge of the start signal should be selected as passive edge. The input signal for the CCU slice should be selected as SCU input. The above mentioned configurations can be made using the CCU LLD API XMC_CCU4_SLICE_StartConfig(). CCU timer slice should be started using XMC_CCU4_SLICE_StartTimer() before triggering the timer using this API.
Related APIs:
XMC_CCU4_SLICE_StartConfig(), XMC_CCU4_SLICE_SetInput(), XMC_SCU_SetCcuTriggerHigh()


Definition at line 255 of file xmc_scu.h.